package com.itheima.Demo;

import java.io.*;
import java.net.Socket;
import java.nio.Buffer;

public class Damo文件上传客户端 {
    public static void main(String[] args) throws IOException {
        //先创建一个网路编程对象;
        Socket s  = new Socket("192.168.50.113",1314);
        //创建输入流
        BufferedInputStream fis = new BufferedInputStream(new FileInputStream("C:\\Users\\97622\\Pictures\\Camera Roll\\张梓墨.jpg"));
        //获取网络编程输出流
        BufferedOutputStream os = new BufferedOutputStream(s.getOutputStream());
        //每次读取一个字节发送给服务器
        byte [] arr  = new byte[1024];
        int i  ;
        while((i=fis.read(arr))!=-1){
            os.write(arr);
        }
        s.shutdownOutput();
        //创建输入流;
        InputStream is = s.getInputStream();
        byte[] array = new byte[1024];
        int i1 ;
        while ((i1 =is.read(array))!=-1){
            System.out.println(new String(array,0,i1));
        }

        //关流;
        s.close();
        fis.close();
    }
}
